package com.freesky.web.manager.controller.system;

import com.freesky.common.dao.entity.SystemInfo;
import com.freesky.common.utils.reponse.JSONResponse;
import com.freesky.web.manager.service.ISystemInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 陈玉林
 * @modifiedBy:
 * @date: Create In 14:58 2019-01-11
 * @description:
 */
@Controller
@Api(description = "系统信息")
@RequestMapping("/system/info")
public class SystemInfoController {
    @Autowired
    private ISystemInfoService systemInfoService;
    @GetMapping("/page")
    @ApiOperation(value = "进入页面-系统信息")
    public String sysInfoPage(Model model) {
        SystemInfo systemInfo = new SystemInfo().selectAll().get(0);
        model.addAttribute("systemInfo", systemInfo);
        return "system/info";
    }

    @ResponseBody
    @PostMapping(value = "/update")
    @ApiOperation(value = "修改系统信息")
    public JSONResponse updateSystemInfo(@ModelAttribute SystemInfo info) {
        return systemInfoService.updateInfo(info);
    }
}
